<?php
/**
 * 菜单服务类
 * User: Woozee
 * Date: 2020/10/29
 * Time: 11:20
 */

namespace App\Services;

use App\Libs\Helpers\Arr;
use App\Responses\Admin\Menu\MenuItem;

class MenuService extends BaseService
{
    /**
     * 获取菜单列表
     *
     * @return MenuItem[]
     */
    public function getList(): array
    {
        $menuConfig = config('menus.admin');

        return MenuItem::fromList($menuConfig);
    }

    /**
     * 获取前端菜单列表
     *
     * @return \App\Responses\Front\Menu\MenuItem[]
     */
    public function getFrontList(): array
    {
        $menuList = config('menus.front');
        $menuList = Arr::sort($menuList, function ($menu) {
            return $menu['sort_id'];
        });

        return \App\Responses\Front\Menu\MenuItem::fromList($menuList);
    }
}
